﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace HelperMethods.Models
{
    //alternativa: Applying Metadata to a Buddy Class


    [DisplayName("New Person")]
    public class Person
    {
       [HiddenInput(DisplayValue = false)]
        //[ScaffoldColumn(false)] //if we want the property out of scaffolding process
        public int PersonId { get; set; }
        [Display(Name = "First")]
        [UIHint("MultilineText")] //name of template to be drawn (DateTime, Date, EmailAddress, HiddenInput, etc)
        public string FirstName { get; set; }
        [Display(Name = "Last")]
        public string LastName { get; set; }
        [Display(Name = "Birth Date")]
        [DataType(DataType.Date)] //shows only date
        public DateTime BirthDate { get; set; }
        public Address HomeAddress { get; set; }
        [Display(Name = "Approved")]
        public bool IsApproved { get; set; }
        [UIHint("Enum")] //forces to use Enum template
        public Role Role { get; set; }
    }

    [MetadataType(typeof(AddressMetadata))]
    public class Address
    {
        public string Line1 { get; set; }
        public string Line2 { get; set; }
        public string City { get; set; }
        public string PostalCode { get; set; }
        public string Country { get; set; }
    }

    public class AddressMetadata
    {
        [Required]
        public string Line1 { get; set; }
    }

    public enum Role
    {
        Admin,
        User,
        Guest
    }
}